# 加入父路径
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
import numpy as np
from cec2020_helper import all_functions_2020
from pyade import de 


algorithm = de 
dim = 10
func_id = 4
for func_id in range(1, 31):
    func = all_functions_2020(dim)[func_id - 1]

    params = algorithm.get_default_params(dim=dim)
    params['bounds'] = np.array([[-100, 100]] * dim)  # 使用默认搜索空间
    params['func'] = func 
    params['max_evals'] = dim * 20000 

    slove, best_fitness, history = algorithm.apply(**params)
    print(f'func_id = {func_id}, best_fitness: {best_fitness}')

 
